package com.mhkj.base.templete.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.mhkj.base.busiType.entity.BusinessType;
import com.mhkj.base.fruitType.entity.FruitType;
import com.mics.core.common.validate.annotation.NotNull;
import com.mics.core.common.validate.annotation.Unique;
import com.mics.core.common.validate.annotation.Validate;
import com.mics.core.system.base.entity.BaseDomain;
import com.mics.core.system.rbac.entity.Dictionary;

/**
 * 计划模板
 * @author mics
 * @date 2018年7月2日
 * @version 1.0
 */
@Entity
@Table(name="t_plan_templete")
@Validate
public class PlanTemplete extends BaseDomain{
	/**
	 * 序列号
	 */
	private static final long serialVersionUID = -6326149877617815832L;
	/**
	 * 名称
	 */
	@NotNull(message="计划模板名称不能为空")
	@Column(name="name",length=48)
	@Unique(message="模板名称必须唯一")
	private String name;
	
	/**
	 * 计划类型
	 */
	@NotNull(message="模板类型不能为空")
	@JoinColumn(name="type_id")
	@ManyToOne(fetch=FetchType.LAZY)
	private Dictionary type;
	
	/**
	 *业务类型
	 */
	@JoinColumn(name="professional_type")
	@ManyToOne(fetch=FetchType.LAZY)
	private BusinessType professionalType;
	
	/**
	 * 创建人姓名
	 */
	@Transient
	private String createUserName;

	
	/**
	 * 审批状态 0未提交   1、审核中 2、审核成功  3、审核失败
	 */
	@Column(name="state")
	private int state=0;
	
	/**
	 * 备注
	 */
	@Column(name="remark",length=500)
	private String remark;
	
	/**
	 * 模板数据
	 */
	@OneToMany(cascade=CascadeType.REMOVE,mappedBy="planTemplete")
	@LazyCollection(LazyCollectionOption.EXTRA)
	private List<PlanTempleteData> planTempleteDatas;
	
	/**
	 * 成果类别
	 */
	@OneToMany(cascade=CascadeType.REMOVE,mappedBy="planTemplete")
	@LazyCollection(LazyCollectionOption.EXTRA)
	private List<FruitType> fruitTypes ;
	
	
	public List<PlanTempleteData> getPlanTempleteDatas() {
		return planTempleteDatas;
	}

	public void setPlanTempleteDatas(List<PlanTempleteData> planTempleteDatas) {
		this.planTempleteDatas = planTempleteDatas;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}


	public String getCreateUserName() {
		return createUserName;
	}

	public void setCreateUserName(String createUserName) {
		this.createUserName = createUserName;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public Dictionary getType() {
		return type;
	}

	public void setType(Dictionary type) {
		this.type = type;
	}

	public BusinessType getProfessionalType() {
		return professionalType;
	}

	public void setProfessionalType(BusinessType professionalType) {
		this.professionalType = professionalType;
	}

	public List<FruitType> getFruitTypes() {
		return fruitTypes;
	}

	public void setFruitTypes(List<FruitType> fruitTypes) {
		this.fruitTypes = fruitTypes;
	}
	
	
	
}
